home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / PlayerPRO 4.5.8 / PlayerPRO 4.5.8 Dev.Kit / MADH Library 4.5 / MacOS Examples / Example.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-25  |  3.5 KB  |  141 lines  |  [TEXT/CWIE]

  1. /********************************************************/
  2. /*
  3.     Player PRO 4.5.2 -- Music Driver EXAMPLE
  4.  
  5.     Library Version 4.02
  6.  
  7.     To use with Think C & CodeWarrior
  8.  
  9.     Antoine ROSSET
  10.     16 Tranchees
  11.     1206 GENEVA
  12.     SWITZERLAND
  13.     
  14.     FAX: (+41 22) 346 11 97
  15.     PHONE: (+41 89) 203 74 62
  16.     Email: rosset@dial.eunet.ch
  17. */
  18. /********************************************************/
  19.  
  20. #include "RDriver.h"            // Mad Driver functions & globals
  21.  
  22. void OSType2Ptr( OSType type, Ptr str)
  23. {
  24.     short i;
  25.     
  26.     BlockMove( &type, str, 4);
  27.     str[ 4] = 0;
  28. }
  29.  
  30. /*****************************/
  31. /****** MAIN FUNCTION ********/
  32. /*****************************/
  33.  
  34. void main( void)
  35. {
  36. Boolean                End = false;
  37.  
  38. /***************                    ****************/
  39. /******          Toolbox Initialization      **********/
  40. /***************                    ****************/
  41.  
  42. InitGraf( &qd.thePort);
  43. InitFonts();
  44. InitWindows();
  45. InitMenus();
  46. TEInit();
  47. InitDialogs(0L);
  48. InitCursor();
  49. MaxApplZone();
  50. MoreMasters();
  51.  
  52. /*******************************************************************************************/
  53. /****** MAD Library Initialisation : choose the best driver for the current hardware  ******/
  54. /******                                                                                  ******/
  55. /****** Standard initialization with 4 channels...                                      ******/
  56. /*******************************************************************************************/
  57.  
  58. {
  59. MADDriverSettings    init;
  60.  
  61.  
  62. /*
  63. MANUAL DRIVER CONFIGURATION, by example:
  64.  
  65. init.numChn                = 4;
  66. init.outPutBits         = 8;
  67. init.outPutRate            = rate22khz;
  68. init.outPutMode            = StereoOutPut;
  69. init.driverMode            = SoundManagerDriver;
  70. init.antiAliasing        = false;
  71. init.repeatMusic        = false;
  72. init.Interpolation        = false;
  73. init.MicroDelay            = false;
  74. init.MicroDelaySize     = 35;
  75. init.surround             = false;
  76. init.sysMemory            = false;
  77. init.Reverb                = false;
  78. init.ReverbSize            = 45;
  79. init.ReverbStrength        = 60;
  80. init.ReverbStrength        = 60;
  81. init.TickRemover        = false;
  82. */
  83.  
  84. /* or AUTOMATIC DRIVER CONFIGURATION FOR CURRENT MAC HARDWARE*/
  85. MADGetBestDriver( &init);
  86.  
  87. if( MADInitLibrary( "Plugs", init.sysMemory) != noErr) DebugStr("\pSmall Problem...");
  88. if( MADCreateDriver( &init) != noErr) DebugStr("\pSmall Problem...");
  89. }
  90. /*********************************/
  91. /*********************************/
  92. /*********************************/
  93.  
  94. /****** Open a music file via Plugs ********/
  95. while( End == false)
  96. {
  97.     StandardFileReply    reply;
  98.     SFTypeList            aType;
  99.     
  100.     FlushEvents( everyEvent, 0);
  101.     
  102.     StandardGetFile( 0L, -1, aType, &reply);
  103.     
  104.     if( !reply.sfGood) End = true;
  105.     else
  106.     {
  107.         char type[ 5];
  108.         
  109.         OSType2Ptr( reply.sfType, type);
  110.         
  111.         if( MADPlugAvailable( type))        // Is available a plug to open this file?
  112.         {
  113.             if( MADLoadMusicFSpFile( type, &reply.sfFile) == noErr)        // Load this music with help of Plugs
  114.                                                                                     // in application folder, in 'Plugs' folder or internal resources
  115.             {
  116.                 MADStartDriver();                // Turn interrupt driver function ON
  117.                 MADPlayMusic();                    // Read the current partition in memory
  118.                 
  119.                 while( !Button())
  120.                 {
  121.                     /// Do what you want here....
  122.                     /// Bla bla...
  123.                     /// By example:    Run your realtime 3D game
  124.                     ///             with 24bit texture mapping...
  125.                     
  126.                     long    fT, cT;
  127.                     
  128.                     MADGetMusicStatus( &fT, &cT);    // Some infos about current music
  129.                 }
  130.                 MADStopMusic();                    // Stop reading current partition
  131.                 MADStopDriver();                // Stop driver interrupt function
  132.                 
  133.                 MADDisposeMusic();                // Dispose the current music
  134.             }
  135.         }
  136.     }
  137. }
  138. MADDisposeDriver();                        // Dispose music driver
  139. MADDisposeLibrary();                    // Close music library
  140. FlushEvents( everyEvent, 0);            // Kill your events and byebye...
  141. }